<template>
  <!--参与者维护明细页面弹出框-->
  <el-dialog
    title="参与者维护维护"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
    v-if="isDestroy"
  >
    <el-form ref="detailsForm" :model="formData" label-width="150px" :rules="rules">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="行号：" prop="bankCode">
            <el-input v-model="formData.bankCode" placeholder="" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="行别代码：" prop="category">
            <el-input v-model="formData.category" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="类别：" prop="bankType">
            <el-select v-model="formData.bankType" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PT_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="一二代标志：" prop="cnapsFlag">
            <el-select v-model="formData.cnapsFlag" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.CNAPS_FLAG_BANK"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属直参行号：" prop="drctBankCode">
            <el-input v-model="formData.drctBankCode" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属法人：" prop="lglPrsn">
            <el-input v-model="formData.lglPrsn" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="本行上级参与机构：" prop="highOrg">
            <el-input v-model="formData.highOrg" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="承接行行号：" prop="bearBrno">
            <el-input v-model="formData.bearBrno" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="管辖人行行号：" prop="chargeBrno">
            <el-input v-model="formData.chargeBrno" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入账行行号：" prop="acctBrno">
            <el-input v-model="formData.acctBrno" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属CCPC：" prop="lglCcpc">
            <el-input v-model="formData.lglCcpc" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所在城市代码：" prop="lglCtCode">
            <el-input v-model="formData.lglCtCode" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="参与机构全称：" prop="orgFullName">
            <el-input v-model="formData.orgFullName" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="加入业务系统标识：" prop="checkBox">
            <el-checkbox-group v-model="checkList" :min="1">
              <el-checkbox label="大额系统"></el-checkbox>
              <el-checkbox label="小额系统"></el-checkbox>
              <el-checkbox label="网银系统"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="电话/电挂：" prop="tel">
            <el-input v-model="formData.tel" placeholder="" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submit" :loading="isLoading">提交</el-button>
      <el-button type="warning" @click="reset" :loading="isLoading">重置</el-button>
      <el-button @click="closeFn">关闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { submit } from "@/api/cnaps/ccms/bankCodeMng/participant_maintenance_query.js";
export default {
  name: "ParticipantQueryMaintain",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示弹出层
      open: false,
      isLoading: false,
      isDestroy: false,
      checkList: [],
      rules: {
        checkBox: [
          {
            required: true,
            message: " ",
          },
        ],
      },
    };
  },
  mounted() {},
  watch: {
    open(d) {
      if (d) {
        this.isDestroy = true;
        let list = this.formData.joinBizFlagDesc.split(" ");
        this.checkList = [list[0], list[1], list[2]];
      }
    },
  },
  methods: {
    // 审批方法
    submit() {
      this.isLoading = true;
      let first = this.checkList.indexOf("大额系统") > "-1" ? (first = "1") : (first = "0");
      let second = this.checkList.indexOf("小额系统") > "-1" ? (second = "1") : (second = "0");
      let third = this.checkList.indexOf("网银系统") > "-1" ? (third = "1") : (third = "0");
      this.formData.joinBizFlag = first + second + third;
      submit({ ...this.formData })
        .then((res) => {
          this.isLoading = false;
          this.$emit("editComplete", true);
          this.msgSuccess("成功!");
          this.closeFn();
        })
        .catch((err) => {
          this.isLoading = false;
          //   this.$alert(`${res.result}`, "系统提示", {
          //     confirmButtonText: "确认",
          //     type: "error",
          //     callback: (action) => {},
        });
      // });
    },
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
      let list = this.formData.joinBizFlagDesc.split(" ");
      this.checkList = [list[0], list[1], list[2]];
    },
    closeFn() {
      this.open = false;
      this.isDestroy = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
  },
};
</script>
